package com.mm.domain.book;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.util.Date;

/**
 * @Description 小说主体信息
 * @Date 2023/10/8 下午3:50
 * @Author yanglin
 **/
@Getter
@Setter
@NoArgsConstructor
@AllArgsConstructor
@ToString
@Accessors(chain = true)
@TableName("d_book_info")
public class DBookInfo {

    /**
     * 序号
     */
    @TableId(value = "book_id", type = IdType.AUTO)
    private Long bookId;

    /**
     * 小说唯一标识(小说地址+标题+作者MD5)
     */
    @TableField("book_unique")
    private String bookUnique;

    /**
     * 小说标题
     */
    @TableField("book_title")
    private String bookTitle;

    /**
     * 书籍网站源
     * 10-书趣阁 20-书本网 30-棉花糖 40-键盘小说
     */
    @TableField("book_web")
    private int bookWeb;

    /**
     * 书籍网站源名称
     * 10-书趣阁 20-书本网 30-棉花糖 40-键盘小说
     */
    @TableField(exist = false)
    public String bookWebName;

    /**
     * 小说简介
     */
    @TableField("book_intro")
    private String bookIntro;

    /**
     * 小说类别
     */
    @TableField("book_category")
    private int bookCategory;

    /**
     * 书籍网站分类
     * 10-玄幻奇幻 20-武侠修真 30-现代都市 40-历史军事 50-游戏竞技 60-科幻灵异 70-女生言情 80-综漫同人 90-其他类型 100-最新
     */
    @TableField(exist = false)
    private String bookCategoryName;


    /**
     * 小说状态
     */
    @TableField("book_state")
    private String bookState;

    /**
     * 小说图片地址
     */
    @TableField("book_img")
    private String bookImg;

    /**
     * 小说地址
     */
    @TableField("book_url")
    private String bookUrl;

    /**
     * 小说下载地址
     */
    @TableField("book_download_url")
    private String bookDownloadUrl;

    /**
     * 小说大小
     */
    @TableField("book_size")
    private int bookSize;

    /**
     * 小说作者
     */
    @TableField("book_author")
    private String bookAuthor;

    /**
     * 小说最后更新章节
     */
    @TableField("last_update_chapter")
    private String lastUpdateChapter;

    /**
     * 小说最新章节地址
     */
    @TableField("last_update_chapter_url")
    private String lastUpdateChapterUrl;

    /**
     * 小说最后更新时间
     */
    @TableField("last_update_time")
    private Date lastUpdateTime;

    /**
     * 小说存储地址
     */
    @TableField("book_local_path")
    private String bookLocalPath;

    /**
     * 书籍网站ID
     */
    @TableId(value = "source_id")
    private Long sourceId;

    public String getBookWebName() {
        String bookWebName = "";
        if (bookWeb == 10) {
            bookWebName = "书趣阁";
        } else if (bookWeb == 20) {
            bookWebName = "书本网";
        } else if (bookWeb == 30) {
            bookWebName = "棉花糖";
        } else if (bookWeb == 40) {
            bookWebName = "键盘网";
        } else if (bookWeb == 50) {
            bookWebName = "奇书网";
        }
        return bookWebName;
    }

    public String getBookCategoryName() {
        String bookCategoryName = "";
        if (bookCategory == 10) {
            bookCategoryName = "玄幻奇幻";
        } else if (bookCategory == 20) {
            bookCategoryName = "武侠修真";
        } else if (bookCategory == 30) {
            bookCategoryName = "现代都市";
        } else if (bookCategory == 40) {
            bookCategoryName = "历史军事";
        } else if (bookCategory == 50) {
            bookCategoryName = "游戏竞技";
        } else if (bookCategory == 60) {
            bookCategoryName = "科幻灵异";
        } else if (bookCategory == 70) {
            bookCategoryName = "女生言情";
        } else if (bookCategory == 80) {
            bookCategoryName = "综漫同人";
        } else if (bookCategory == 90) {
            bookCategoryName = "其他类型";
        } else if (bookCategory == 100) {
            bookCategoryName = "最近更新";
        }
        return bookCategoryName;
    }
}
